
<template>
	<!-- 添加弹框 -->
	<el-dialog title="" width="60%" visible :show-close="false" :append-to-body="true" class="wrap" >
		<i class="el-icon-close close" @click="cancel" style="color: white;z-index: 99;"></i>
		 <div class="bt">添加教室时间段</div>
		<el-form label-width="100px" class="form">
			<el-form-item label="上课时段">
				  <el-select v-model="vsjqj" placeholder="请选择时段" class="select-block">
                    <el-option label="上午" value="上午"></el-option>
                    <el-option label="下午" value="下午"></el-option>
                    <el-option label="夜晚" value="夜晚"></el-option>
                </el-select>
			</el-form-item>
			<el-form-item label="上课时间" >
		     <div class="left" style="width:230px;float: left;">
		     	<div style="float: left; " ></div>
			 <div class="search-item" style="width: 80px;float: left;">
                <el-select v-model="form.btimeh" style="float: left;">
				<el-option label="06"	value="06"></el-option>
				<el-option label="07"	value="07"></el-option>
				<el-option label="08"	value="08"></el-option>
				<el-option label="09"	value="09"></el-option>
				<el-option label="10"	value="10"></el-option>
				<el-option label="11"	value="11"></el-option>
				<el-option label="12"	value="12"></el-option>
				<el-option label="13"	value="13"></el-option>
				<el-option label="14"	value="14"></el-option>
				<el-option label="15"	value="15"></el-option>
				<el-option label="16"	value="16"></el-option>
				<el-option label="17"	value="17"></el-option>
				<el-option label="18"	value="18"></el-option>
				<el-option label="19"	value="19"></el-option>
				<el-option label="20"	value="20"></el-option>
				<el-option label="21"	value="21"></el-option>
				<el-option label="22"	value="22"></el-option>
                </el-select>
            </div>
            <div style="float: left; " >&nbsp;&nbsp;:&nbsp;&nbsp;</div>
            <div class="search-item" style="width: 80px;float: left;">
                <el-select v-model="form.etimem">
				<el-option label="00"	value="00"></el-option>
				<el-option label="05"	value="05"></el-option>
				<el-option label="10"	value="10"></el-option>
				<el-option label="15"	value="15"></el-option>
				<el-option label="20"	value="20"></el-option>
				<el-option label="25"	value="25"></el-option>
				<el-option label="30"	value="30"></el-option>
				<el-option label="35"	value="35"></el-option>
				<el-option label="40"	value="40"></el-option>
				<el-option label="45"	value="45"></el-option>
				<el-option label="50"	value="50"></el-option>
				<el-option label="55"	value="55"></el-option>
                </el-select>
            </div>
            <div class="a" style="float: right;margin-right: 20px;">--</div>
            </div>


		    <div class="left" style="width:230px;float: left;">
		     	<div style="float: left; " ></div>
			 <div class="search-item" style="width: 80px;float: left;">
                <el-select v-model="form.btimeh2" style="float: left;">
				<el-option label="06"	value="06"></el-option>
				<el-option label="07"	value="07"></el-option>
				<el-option label="08"	value="08"></el-option>
				<el-option label="09"	value="09"></el-option>
				<el-option label="10"	value="10"></el-option>
				<el-option label="11"	value="11"></el-option>
				<el-option label="12"	value="12"></el-option>
				<el-option label="13"	value="13"></el-option>
				<el-option label="14"	value="14"></el-option>
				<el-option label="15"	value="15"></el-option>
				<el-option label="16"	value="16"></el-option>
				<el-option label="17"	value="17"></el-option>
				<el-option label="18"	value="18"></el-option>
				<el-option label="19"	value="19"></el-option>
				<el-option label="20"	value="20"></el-option>
				<el-option label="21"	value="21"></el-option>
				<el-option label="22"	value="22"></el-option>
                </el-select>
            </div>
            <div style="float: left;">&nbsp;&nbsp;:&nbsp;&nbsp;</div>
            <div class="search-item" style="width: 80px;float: left;">
                <el-select v-model="form.etimem2">
				<el-option label="00"	value="00"></el-option>
				<el-option label="05"	value="05"></el-option>
				<el-option label="10"	value="10"></el-option>
				<el-option label="15"	value="15"></el-option>
				<el-option label="20"	value="20"></el-option>
				<el-option label="25"	value="25"></el-option>
				<el-option label="30"	value="30"></el-option>
				<el-option label="35"	value="35"></el-option>
				<el-option label="40"	value="40"></el-option>
				<el-option label="45"	value="45"></el-option>
				<el-option label="50"	value="50"></el-option>
				<el-option label="55"	value="55"></el-option>
                </el-select>
            </div>
            </div>
			</el-form-item>
			<span style="color: red;">注：采用24小时制的时间模式</span>
			<el-form-item label="启用状态">
				<el-tooltip :content="'Switch value: ' +form.visenable" placement="top">
					<el-switch v-model="form.visenable" active-color="#13ce66" inactive-color="#ff4949" inactive-text="禁用" active-text="启用" active-value="Y" inactive-value="N"></el-switch>
				</el-tooltip>
			</el-form-item>
			<el-form-item label="说明">
				<el-input v-model="form.vnotes" type="textarea" :rows="2" placeholder="请输入内容" class="select-block"></el-input>
			</el-form-item>

		</el-form>
		<el-button type="primary" class="submit" @click="submit">保存</el-button>
		<el-button type="danger" class="submit1" @click="cancel">退出</el-button>
		
	</el-dialog>
</template>
<script type="text/javascript">
	import qs from 'qs'
	export default {
 		props: ['params'],
		data() {
			return {
				form: {
				   btimeh:'',
		           btimeh2:'',
		           etimem:'',
		           etimem2:'',
					visenable: 'Y',
					vnotes: '',

					vxh: '',

				},
				vjsid: '',
				vsjqj:'',
				timeduan:'',
				dialogTableVisible: true
			}
		},
		created(){
			// alert( this.params);
		},
		methods: {
			submit() {
				    var arr = this.form.btimeh+":"+this.form.etimem
 			 		var arr2 = this.form.btimeh2+":"+this.form.etimem2

 			 		var arr3 = arr+"--"+arr2
					if(arr3.length<12){
						this.$message.error("请正确选择时间段");
						return
					}
				// console.log(this.timeduan)
				//检测
				// this.$store.state.loading = true;
			   /* if(!this.mc) {
					this.$message.warning('请填写分类名称');
					this.$store.state.loading = false;
					return;
				} */
				var logininfo = JSON.parse(localStorage.logininfo);
//				var time1 = this.$.getLocalTimeNo1(Date.parse(this.timeduan[0]));
//				var time2 = this.$.getLocalTimeNo1(Date.parse(this.timeduan[1]));
//				var time3 = (time1+"--"+time2)
				var params3 = qs.stringify({
					jsid:this.params,
					sjd: arr3,
					sjqj:this.vsjqj,
					notes: this.form.vnotes,
					xh: this.form.vxh,
					isenable: this.form.visenable,
					yhid: logininfo.id,
					xxid:logininfo.xxid
				});
				//执行
				this.axios.post(this.$store.state.api + 'jssjd/insert', params3)
					.then(res => {
						console.log(res)
						if(res.data.code == 1) {
							this.$emit('close', { type: 'add', cancel: false });
							this.$store.state.loading = false;
						} else {
						    this.$message.warning(res.data.msg);
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.warning("服务器繁忙，请重试");
						this.$store.state.loading = false;
					})
			},
			cancel() {
				this.$emit('close', { type: 'add', cancel: true })
			}
		}
	}
</script>
<style lang="less" scoped>
	.wrap {
		.input-block {
			margin-bottom: 20px;
			text-align: center;
		}
		.bt{
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top:0;
			left:0;
			background: #50BFFF;
			margin-bottom: 20px;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
		.form{
			/*text-align: center;*/
			margin-top: 20px;
		}
			.select-block {
 		display: block;
 		width: 85%;
 	}
		.input {
			display: inline-block;
		}
		.submit {
			width: 120px;
			margin-left: 35%;
		}.submit1 {
			width: 120px;
			margin-left: 0%;
		}
	}
</style>
